package com.zj.blessings.util;

import android.app.Activity;

import java.util.LinkedList;

public class ActivityUtils {
	private static LinkedList<Activity> activities;
	private static ActivityUtils instance = null;

	private ActivityUtils() {
	}

	public static ActivityUtils getInstance() {
		if (instance == null) {
			instance = new ActivityUtils();
			activities = new LinkedList<Activity>();
		}
		return instance;
	}

	public void Add(Activity acy) {
		activities.add(acy);
	}

	public void Remove(Activity acy) {
		activities.remove(acy);
	}

	public void CloseAll() {
		Activity acy;
		while (activities.size() != 0) {
			acy = activities.poll();
			if (acy != null && !acy.isFinishing())
				acy.finish();
		}
	}
}